package com.example.shopping.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/*
Create by 苍狼 于 2020/1/29
站在巅峰看世界，
落在深渊思人生。
*/

/**
 * 配置错误页面
 */
@Configuration
public class ErrorPageConfig implements ErrorPageRegistrar {
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        /*错误类型为404，找不到网页的，默认显示404.html网页*/
        ErrorPage e404 = new ErrorPage(HttpStatus.NOT_FOUND, "/static/error/error.html");
        /*错误类型为500，表示服务器响应错误，默认显示500.html网页*/
        ErrorPage e500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/static/error/error.html");
        ErrorPage e400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/static/error/error.html");
        registry.addErrorPages(e400 ,e404, e500);

    }
}
